<%-- 
    Document   : insertaProducto
    Created on : 20/06/2013, 10:18:25 PM
    Author     : Neto
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>COMPRA</title>

        <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/resources/dhtmlxSuite/dhtmlxForm/codebase/skins/dhtmlxform_dhx_web.css">
        <script src="${pageContext.request.contextPath}/resources/dhtmlxSuite/dhtmlxForm/codebase/dhtmlxcommon.js"></script>
        <script src="${pageContext.request.contextPath}/resources/dhtmlxSuite/dhtmlxForm/codebase/dhtmlxform.js"></script>


    </head>
    <body>
         <div id="myForm" style="font-size:17px; width:260px; height:270px; margin-left: -3px;"></div> 
        <script>
           var myForm,
            formData;
    dhtmlx.skin = "dhx_web";
            formData = [{
                    type: "settings",
                    position: "label-left",
                    labelWidth: 130,
                    inputWidth: 150
                }, {  
                    type: "fieldset",
                    label: "",
                    inputWidth: "auto",
                    list: [
                         {
                            type: "input",
                            label: "Clave Producto",
                            name: "claveProducto",
                            value: "",
                            validate: "NotEmpty,ValidAplhaNumeric,valLimClave",
                            info: true, 
                            tooltip: "Maximo 20 Caracteres",
                            required: true,
                              note: { text:"Inserta Maximo 20 Caracteres"}
                        },{
                            type: "input",
                            label: "Nombre",
                            name: "nombre",
                            value: "",
                            validate: "NotEmpty",
                            tooltip: "",
                            required: true,
                             note: { text:"nombre del producto"}
                     },{
                            type: "input",
                            label: "Detalles",
                            name: "detalles",
                            value: "",
                            validate: "NotEmpty",
                            rows: 3,
                            style:"width:230px;",
                            required: true,
                            note: { text:"Detalles del producto"}
                        },{
                            type: "input",
                            name:"precio",
                            label: "Precio",
                            value: "",
                            validate: "NotEmpty,ValidNumeric",
                            required: true,
                             note: { text:"precio del producto"}
                        },{
                            type: "button",
                            name:"guardar",
                            value: "Guardar"
                        }]
                }];
            
           function valLimClave(data){
        if (data=="") return true;// returns 'true' if the field is empty
        return (data.length<=20);
}
            myForm = new dhtmlXForm("myForm", formData);
             myForm.enableLiveValidation(true);
             myForm.attachEvent("onButtonClick", function(id) {
                  if(id=="guardar"){  
                  if(myForm.validate()){
                      myForm.send("insertpro","post");
                         var pagina="../administrador/admoProductos";
                location.href=pagina;
                  }
             //     location.reload();
          }
           });
           
          /* myForm.attachEvent("onButtonClick", function(id) {
                  if(id=="atras"){  
                         var pagina="../administrador/admoProductos";
                location.href=pagina;
                  }
                  });*/
                  
        </script>
    </body>
</html>

